{include file="public/header" /}
<link href="/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
<body class="gray-bg">
<div class="animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>sql文件列表(备份文件数量：{$filenum}，占空间大小：{$total|format_bytes})</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="table_basic.html#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form id="export-form" method="post" action="{:url('export')}">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>备份名称</th>
                            <th>卷数</th>
                            <th>压缩</th>
                            <th>数据大小</th>
                            <th>备份时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {notempty name="data"}
                            {volist name="data" id="vo"}
                            <tr>
                                <td>{$vo.basename}</td>
                                <td>{$vo.part}</td>
                                <td>{$vo.compress}</td>
                                <td>{$vo.size|format_bytes}</td>
                                <td>{$vo.time}</td>
                                <td>-</td>
                                <td>
                                    <a class="btn btn-primary btn-xs btn-outline db-import" href="{:url('revert',['time'=>$vo['time']])}">还原</a>
                                    <a class="btn btn-danger btn-xs btn-outline" onclick="del('{$vo['time']}')">删除</a>
                                </td>
                            </tr>
                            {/volist}
                        {else /}
                            <td colspan="7" class="text-center"> 暂未发现数据库表! </td>
                        {/notempty}
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

{include file="public/footer" /}

<script type="text/javascript">
        $(function () {

            $(".db-import").click(function () {
                var self = this, status = ".";
                $.get(self.href, success, "json");
                window.onbeforeunload = function () { return "正在还原数据库，请不要关闭！";};
                return false;
                function success(data) {
                    if (data.code) {
                        if (data.data.gz) {
                            data.msg += status;
                            if (status.length === 5) {
                                status = ".";
                            } else {
                                status += ".";
                            }
                        }
                        $(self).parent().prev().text(data.msg);
                        if (data.data.part) {
                            $.get(self.href, {"part": data.data.part, "start": data.data.start}, success, "json");
                        } else {
                            window.onbeforeunload = function () {return null;};
                        }
                    } else {
                        layer.alert(data.msg,0);
                    }
                }
            });
        });
        function del(time) {
            $.post("{:url('data/del')}",{time:time},function (res) {
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function () {
                        window.location.reload();
                    });
                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }
            })
        }

</script>
</body>
</html>